<?php 
// No direct access to this file
defined('_JEXEC') or die;

$helper = new ProductCartHelper(); 
$cart = $helper->getCart();
$total = $helper->getTotal();
$hasProduct = isset($cart) && count($cart) > 0;
?>
<div class="shoppingCart">
	<div class="top-cart">
		<span class="cart-ico">
			<img src="http://24x7themes.com/metro/skin/frontend/default/metro-blue/images/cart.png" />
		</span>
		<span class="top-content">
			<span class="summary">
        		<span class="shop-title">Shopping: </span>
        		<span class="shop-total">
        			Tổng cộng: <span class="price"><?php echo number_format($total, 0, ',', '.'); ?> đ</span>
        		</span>
			</span>
		</span>
	</div>
	<?php if ($hasProduct) { ?>
		<div class="cartView" style="display: none;">
			<p class="block-subtitle">Sản phẩm đã chọn</p>
			<ol class="mini-products-list" id="cart-sidebar">
				<?php foreach ($cart as $item) { ?>
					<li class="item last odd">
						<a class="product-image" title="Pocket ultra slim fit jeans" href="<?php echo $item['link']; ?>">
							<img width="50" height="50" alt="Pocket ultra slim fit jeans" src="<?php echo $item['thumbnail']; ?>" />
						</a>
			        	<div class="product-details">
			        		<a class="btn-remove" onclick="return confirm('Bạn muốn xóa sản phẩm này ra khỏi giỏ hàng?');" title="Xóa sản phẩm" href="<?php echo $item['deleteLink']; ?>">
			        			Xóa sản phẩm
			        		</a>
			                <p class="product-name">
			                	<a href="<?php echo $item['link']; ?>"><?php echo $item['data']->name; ?></a>
			                </p>
			        		<strong><?php echo $item['qty']; ?></strong> x <span class="price">
			        			<?php echo number_format($item['price'], 0, ',', '.'); ?>
		        			</span>
			            </div>
					</li>
				<?php } ?>
			</ol>
			<div class="actions">        
				<p class="view-cart">
		        	<a href="<?php echo JRoute::_('index.php?option=com_product&view=cart'); ?>">Xem giỏ hàng</a>
		        </p>
		        <button class="button" title="Checkout" type="button"
		        		onclick="window.location='<?php echo JRoute::_('index.php?option=com_product&view=checkout'); ?>';">
		        	<span><span>Đặt hàng</span></span>
		        </button>
			</div>
		</div>
	<?php } else { ?>
		<div class="cartView top-empty" style="display: none;">
        	<p>Bạn chưa có sản phẩm nào trong giỏ hàng.</p>
        </div>
	<?php } ?>
</div>

